package com.fantesy.jwtdemo.config;

import com.fantesy.jwtdemo.filter.TokenFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.FilterRegistration;

/**
 * @author fantsey
 * @date 2020/2/27
 */
@Configuration
public class FilterConfig {

    @Bean
    public FilterRegistrationBean tokenFilter(){
        FilterRegistrationBean registrationBean = new FilterRegistrationBean();
        registrationBean.setFilter(new TokenFilter());
        registrationBean.setEnabled(true);
        registrationBean.addUrlPatterns("/*");
        registrationBean.setOrder(1);
        registrationBean.setName("tokenFilter");
        return registrationBean;
    }

}
